﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RestSharp;
using WeiTalk.SinaEntities.Messages;
using WeiTalk.OAuth;

namespace WeiTalk.Interfaces.Sina
{
    public class MessagesAPI : WeiBoAPIs
    {
        const string directMessagesUrl = "http://api.t.sina.com.cn/direct_messages.json";
        public MessagesAPI(RestClient client) : base(client) { }

        public void GetDirectMessages(Action<IRestResponse<Messages>> callback, string since_id, string max_id = "0", int page = 1)
        {
            RestRequest request = new RestRequest(directMessagesUrl, Method.GET);
            request.AddParameter("source", Utility.ConsumerKey);
            request.AddParameter("access_token", Utility.AccessToken.Token);
            request.AddParameter("since_id", since_id);
            request.AddParameter("max_id", max_id);
            request.AddParameter("page", page);
            request.AddParameter("timestamp", Guid.NewGuid().ToString());
            Client.ExecuteAsync<Messages>(request, callback);
        }
    }
}
